﻿Module TaskAdministrator
    Public Sub save(ByRef task As Task)
        If (task.idProperty <> Nothing And task.idProperty > 0) Then
            update(task)
        Else
            insert(task)
        End If
    End Sub

    Private Sub insert(ByRef task As Task)
        TaskDao.insert(task)
    End Sub

    Private Sub update(ByRef task As Task)
        TaskDao.update(task)
    End Sub

    Public Sub updateStartDateTask(ByRef task As Task)
        TaskDao.updateStartDateTask(task)
    End Sub

    Public Sub updateEndDateTask(ByRef task As Task)
        TaskDao.updateEndDateTask(task)
    End Sub

    Public Function search() As Data.DataTable
        Return TaskDao.searchDataByFilterToSearchForm(New Task())
    End Function

    Public Function searchDataByFilter(ByRef task As Task) As Data.DataTable
        Return TaskDao.searchDataByFilter(task)
    End Function

    Public Function searchDataByFilterToSearchForm(ByRef task As Task) As Data.DataTable
        Return TaskDao.searchDataByFilterToSearchForm(task)
    End Function

    Public Function searchDataById(ByRef id As Integer) As Task
        Dim task As Task = TaskDao.searchDataById(id)
        Return task
    End Function
End Module
